import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

import Home from "./pages/Home";
import Index from "./pages/Index";

export default new Router({
  routes: [
    {
      path: "/",
      name: "home",
      component: Home,
      redirect: "/index",
      children: [
        {
          path: "/index",
          name: "index",
          component: Index,
        },
        {
          path: "/detail/:id",
          name: "detail",
          component: () => import("./pages/DetailPage.vue"),
        },
      ],
    },
    {
      path: "/chat",
      name: "chat",
      component: () => import("./pages/Chat.vue"),
    },
    {
      path: "/login",
      name: "login",
      component: () => import("./pages/Login.vue"),
    },
    {
      path: "/cart",
      name: "cart",
      component: () => import("./pages/Cart.vue"),
    },
    {
      path: "/address",
      name: "address",
      component: () => import("./pages/Address.vue"),
    },
    {
      path: "/create-order",
      name: "create-order",
      component: () => import("./pages/CreateOrder.vue"),
    },
    {
      path: "/searchResult/:keywords",
      name: "searchResult",
      component: () => import("./pages/SearchResultPage.vue"),
    },
    {
      path: "/order",
      name: "order",
      component: () => import("./pages/OrderPage.vue"),
      children: [
        {
          path: "list",
          name: "order-list",
          component: () => import("./pages/OrderListPage.vue"),
        },
        {
          path: "detail",
          name: "order-detail",
          component: () => import("./pages/OrderDetail.vue"),
        },
      ],
    },
  ],
  mode: "history",
});
